<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/*
 * C_Basic_Product_Edit
 *
 * 基础物品编辑类
 *
 */

class C_Basic_Product_Edit extends MY_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('Product_Model');
        $this->load->model('System_Model');
    }

    /*
     * index
     * 初始化
     */

    public function index($id = FALSE) {
        $data['title'] = $this->System_Model->get_system('login_title');
        //判断是否为编辑信息
        $data['entity'] = $this->Product_Model->GetEntity($id);

        $this->load->view('layout/header', $data);
        $this->load->view('layout/menu');
        $this->load->view('basic/basic_product_edit_view', $data);
        $this->load->view('layout/footer');
    }

    /*
     * edit_Product
     * 编辑数据库信息
     */

    function edit_Product() {
        $pt_id = $this->input->post('pt_id');
        $data = array(
            'pt_id' => $pt_id,
            'pt_name' => $this->input->post('pt_name'),
            'pt_units' => $this->input->post('pt_units'),
            'pt_state' => OBJ_STATE_VALID
        );

        if ($pt_id != NULL || $pt_id != "") {
            $this->Product_Model->UpdateEntity($pt_id, $data);
        } else {
            $this->Product_Model->Insert_Product($data);
        }
        //跳转
        redirect('basic/C_Basic_Product_List');
    }

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */